package com.kfm.base.thread.day03;

public class Demo15 {

    public static void main(String[] args) {
        Thread1 t1 = new Thread1();
        Thraed2 t2 = new Thraed2();

        t1.start();
        t2.start();
    }
}

class Thread1 extends Thread {
    public static volatile int money = 10000;

    @Override
    public void run() {
        while (money == 10000) {

        }
        System.out.println("私房钱变了");
    }
}

class Thraed2 extends Thread {

    @Override
    public void run(){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        Thread1.money = 1;
        System.out.println("偷到手了");
    }
}
